package handler

import (
	"github.com/gin-gonic/gin"
	"math/rand"
	"strconv"
	"tapd_c/rpc"
	"tapd_c/tools"
	"time"
)

type Tap struct {
}

func (receiver *Tap) Export(ctx *gin.Context) {
	c, conn := rpc.Init()
	defer conn.Close()
	//获取本周的开始结束时间
	nowBegin, nowEnd := tools.WeekIntervalTime(0)
	//获取上周的开始结束时间
	lastBegin, lastEnd := tools.WeekIntervalTime(-1)
	rand.Seed(time.Now().Unix())
	fileName := time.Now().Format("2006-01-02") + "_tapd_" + strconv.Itoa(rand.Intn(2000))
	rpc.RunServerFuc(c, nowBegin, nowEnd, lastBegin, lastEnd, fileName)
}
